package com.lyl.domaindemo.repository.user;

import com.lyl.domaindemo.domain.user.User;
import com.lyl.domaindemo.domain.user.UserServiceRepository;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @author lyl
 * @date 2023/5/18
 */
@Component
public class UserServiceRepositoryImpl implements UserServiceRepository {

    private final UserRepository userRepository;

    public UserServiceRepositoryImpl(UserRepository userRepository) {
        this.userRepository = userRepository;
    }

    @Override
    public Page<User> getUsers(Pageable pageable) {
        return userRepository.findAll(pageable);
    }

    @Override
    public void saveUser(User user) {
        userRepository.save(user);
    }

    @Override
    public void deleteUser(List<Long> ids) {
        userRepository.deleteAllByIdInBatch(ids);
    }
}
